package bamin.com.bamindaijia.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.aiton.administrator.shane_library.shane.widget.SingleBtnDialog;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import bamin.com.bamindaijia.R;
import bamin.com.bamindaijia.constant.Constant;
import cz.msebera.android.httpclient.Header;

public class WalletActivity extends ZjbBaseActivity implements View.OnClickListener {

    private TextView mTv_wallet_num;
    private int mUsetId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wallet);
        init();
    }

    @Override
    protected void initData() {
        String url = "";
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        RequestParams params = new RequestParams();
        params.put("", "");//用户ID
        asyncHttpClient.post(url, params, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                String s = new String(responseBody);
                try {


                    cancelLoadingDialog();
                } catch (Exception e) {

                }
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                cancelLoadingDialog();
                Toast.makeText(WalletActivity.this, "网络请求失败", Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override
    protected void initViews() {

    }

    @Override
    protected void setListeners() {
        findViewById(R.id.imageView_back).setOnClickListener(this);
        findViewById(R.id.rela_wallet).setOnClickListener(this);
        findViewById(R.id.rela_invoice).setOnClickListener(this);

    }

    @Override
    protected void initSP() {

    }

    @Override
    protected void initIntent() {
        Intent intent = getIntent();
        mUsetId = intent.getIntExtra(Constant.INTENT_KEY.USER_ID, -1);
        if (mUsetId == -1) {
            final SingleBtnDialog singleBtnDialog = new SingleBtnDialog(this, "用户信息出错", "确定");
            singleBtnDialog.setClicklistener(new SingleBtnDialog.ClickListenerInterface() {
                @Override
                public void doWhat() {
                    finishTo();
                    singleBtnDialog.dismiss();
                }
            });
            singleBtnDialog.show();
        }

    }

    @Override
    protected void findID() {
        mTv_wallet_num = (TextView) findViewById(R.id.tv_wallet_num);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch (v.getId()) {
            case R.id.imageView_back:
                finishTo();
                break;
            case R.id.rela_wallet://余额
                intent.setClass(this,WalletTopUpActivity.class);
                startActivityTo(intent);
                break;
            case R.id.rela_invoice://发票
                Intent intent1 = InvoiceActivity.newIntent(this, mUsetId);
                startActivityTo(intent1);
                break;

        }
    }
}
